﻿using Inovout.Data.Domain;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace KuaJing.Organization.Domain
{
    public partial class Position : IOrganizationStructural
    {
        IEnumerable<IDepartment> IOrganizationStructural.Children
        {
            get { throw new System.NotImplementedException(); }
        }

        [DataProperty("部门", DataType.Text, null, true, null, null)]
        [Select(SelectType.ComboTree, "Name")]
        public virtual OrganizationUnit Organization
        {
            get { return this.Organizations.FirstOrDefault(); }
            set
            {
                var organization = this.Organizations.FirstOrDefault();
                if (organization != null)
                {
                    this.Organizations.Remove(organization);
                }
                this.Organizations.Add(value);
            }
        }
    }
}
